var addProject=null;
$(function () {
    addProject=new AddProject();
});
(function(){
    var AddProject = window.AddProject = function(){
        return new AddProject.prototype.init();

    };
    AddProject.fn = AddProject.prototype = {
        urls:{
            getPictureById:"/admin/api/project/getPictureById?pid="
        },

        init:function () {
            this.initOpt();
            this.initEvent();
            this.initImages();
            return this;
        },
        initOpt:function () {
            var that=this;

        },
        initEvent:function () {
            var that=this;
        },
        initImages:function () {
            var that=this;
            debugger
           var imagesId=$( "input[name='imageIds']").val();
            var html='';
           if(imagesId!=""&&imagesId!=null){
               var ids=imagesId.split(',');
               for(var i=0;i<ids.length;i++){
                   var id=ids[i];
                   if(id!=""&&id!=null){
                       var url=that.urls.getPictureById+id;
                       var isValid=that.validateImagePath(url);
                       html+='<div class="upload-item succeed">' +
                           '<img src="'+url+'">' +
                           '<input id="1600935096361-'+id+'" type="hidden" name="image[]" value="" ' +
                           'imageId="'+id+'">' +
                           '<i class="upload-item-close layui-icon layui-icon-close"></i></div>'
                   }
               }
               $("#J_projectFiles").html(html);
           }
        },

        /**
         * 判断服务是否可用
         */
        validateImagePath:function (url) {
            let errorMsg=true;
            $.ajax({
                type: "GET",
                async: false,
                url: url,
                error:function () {
                    errorMsg=false
                }
            });
            return errorMsg;
        },

    };
    AddProject.fn.init.prototype = AddProject.fn;
})();




